package regex;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @Author: Yangu
 * @Created time: 2021/1/12 11:52
 * @Description :
 */
public class RegexTest {

    //不包含】 正则写法 [^】]
    public static void main(String[] args) {
//        String regex = "(?<=\\\\[)(\\\\S+)(?=\\\\])|(?<=【)[^】]*";
//        String regex = "(?<=【).*(?=(?:】))";
        String regex = "(?<=(?:【)).*(?=(?:】))";

        Pattern pattern = Pattern.compile(regex);
        String str = "3个月内踩盘【5】次，踩盘【4】个，看房轨迹集中在【深圳市-龙华区-梅林关a，深圳市-宝安区-宝安中心b，深圳市-南山区-大学城c，深圳市-南山区-大学城d，深圳市-南山区-大学城e，深圳市-南山区-大学城f】";
        Matcher m = pattern.matcher(str);
        List<String> matchRegexList = new ArrayList<String>();
        while(m.find()){
            m.group(0);
            matchRegexList.add(m.group());
        }
        System.out.println(Arrays.toString(matchRegexList.toArray()));
    }
}
